#include "ContentWidget.h"
#include "DetailWidget.h"
#include <QStylePainter>
#include <QWindow>
#include <QTreeWidget>
#include <QHeaderView>
#include <QtWidgets/QHBoxLayout>
#include <core/comdefs.h>
#include <core/ImageMgr.h>
#if WIN32
#include <Windows.h>
#include <winuser.h>
#endif

ContentWidget::ContentWidget(QWidget* parent)
    : QWidget(parent)
{
	setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
	setupUi();
}

ContentWidget::~ContentWidget()
{

}

void ContentWidget::setupUi()
{
	QHBoxLayout* hLayout = new QHBoxLayout(this);
	hLayout->setSpacing(0);
	hLayout->setContentsMargins(0, 0, 0, 0);
	hLayout->setObjectName(QString::fromUtf8("hLayout"));
	
	QTreeWidget* tree = new QTreeWidget();
	QStringList str1;
	str1 << tr("用例");
	QTreeWidgetItem* bootNode = new QTreeWidgetItem(str1);
//	bootNode->setFlags(Qt::ItemIsSelectable);
//	bootNode->setSelected(false);

	QStringList str2;
	str2 << tr("用户权限");
	QTreeWidgetItem* node1 = new QTreeWidgetItem(str2);
	node1->setText(1, "添加第二列文本");
	bootNode->addChild(node1);
	tree->addTopLevelItem(bootNode);
	tree->setCurrentItem(node1);
	tree->header()->setHidden(true);
	tree->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
	tree->header()->setStretchLastSection(false);
	tree->expandAll();
	tree->setFixedWidth(300);
	tree->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
	tree->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
	tree->setSelectionMode(QAbstractItemView::SingleSelection);
	tree->setStyleSheet("QTreeView {\
			border:none;\
			outline:0px;\
			font-size: 12pt;\
			background: #172422;\
			show - decoration - selected: 1;\
		}\
		QTreeView::item{\
			height: 23px;\
			border: none;\
			color: #FFEBC8;\
		}\
		QTreeView::item:hover{\
			 background: #133E38;\
		}\
		QTreeView::item:selected:!active{\
			background: #133E38;\
		}\
		QTreeView::item:selected:active{\
			background: #133E38;\
		}\
	");

	hLayout->addWidget(tree);

	DetailWidget* detail = new DetailWidget();
	detail->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
	hLayout->addWidget(detail);

	this->setLayout(hLayout);
}

void ContentWidget::paintEvent(QPaintEvent* event)
{
    QStylePainter painter(this);
}

void ContentWidget::resizeEvent(QResizeEvent* event)
{
}
